// components/store/info.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    store: {
      type: Object,
      value: {},
      observer(store) {
        if (store.distance) {
          this.setData({
            distance: (store.distance * 1).toFixed(2)
          })

        }
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    distance: ""
  },

  /**
   * 组件的方法列表
   */
  methods: {
    kf_click() {
      wx.openCustomerServiceChat({
        corpId: 'ww72ede85652b45a26',
        extInfo: {
          url: this.properties.store.customerUrl,
        },
        success: (res) => {
          console.log('打开成功', res);
        },
        fail: (res) => {
          console.log('打开失败', res);
          wx.showToast({
            title: '打开失败',
            icon: 'error'
          })
        },
      })
    },
    location_click() {
      wx.openLocation({
        latitude: this.properties.store.latitude * 1,
        longitude: this.properties.store.longitude * 1,

        fail: (res) => {
          wx.showToast({
            title: JSON.stringify(res),
          })
        },
        complete: (res) => {},
      })
    },
  }
})